package logic

import (
	"context"
	"smart-health-platforms/pkg"
	"user_srv/internal/dao"
	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type MarkMessageReadLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewMarkMessageReadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MarkMessageReadLogic {
	return &MarkMessageReadLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 标记消息已读
func (l *MarkMessageReadLogic) MarkMessageRead(in *user.MarkMessageReadReq) (*user.MarkMessageReadResp, error) {
	err := dao.MarkMessageRead(in.MessageId, int(in.IsRead)) // 标记消息已读
	if err != nil {
		pkg.Warn("标记消息已读失败")
		return nil, err
	}
	return &user.MarkMessageReadResp{
		Success: true,
	}, nil
}
